<template>
  <div class="dashboard_container">
    <div class="card-title">设备接入</div>
    <div class="card-main">
      <div>设备接入率</div>
      <div>
        {{
          deviceData.checked == 0
            ? 0
            : (
                (deviceData.checked * 100) /
                (deviceData.checked + deviceData.uncheck)
              ).toFixed(0)
        }}%
      </div>
    </div>
    <div class="card-foot">
      <div class="line">
        <div>设备总数</div>
        <div>
          {{ (deviceData.checked + deviceData.uncheck).toFixed(0) }}
        </div>
      </div>
      <div class="line">
        <div>接入</div>
        <div>{{ deviceData.checked || 0 }}</div>
      </div>
      <div>
        <div>未接入</div>
        <div v-if="deviceData.uncheck > 0" class="jump_dom" @click="jumpPage">
          {{ deviceData.uncheck || 0 }}
          <img src="@/assets/images/jump_icon.png" alt="" />
        </div>
        <div class="text-value" v-else>
          {{ deviceData.uncheck || 0 }}
        </div>
      </div>
    </div>
    <div class="ball">
      <span>
        {{
          deviceData.checked == 0
            ? 0
            : (
                (deviceData.checked * 100) /
                (deviceData.checked + deviceData.uncheck)
              ).toFixed(0)
        }}%</span
      >
    </div>
  </div>
</template>

<script setup lang="tsx">
import { ref } from 'vue';
import router from '@/router';

const props = defineProps({
  deviceData: {
    type: Object,
    default: () => {},
  },
});

const jumpPage = () => {
  router.push('devices/device');
};
</script>

<style lang="scss" scoped>
@use '../style.scss';
</style>
